home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2007 January, February, March & April
/
Chip-Cover-CD-2007-02.iso
/
Pakiet bezpieczenstwa
/
mini Pentoo LiveCD 2006.1
/
mpentoo-2006.1.iso
/
livecd.squashfs
/
usr
/
lib
/
python2.4
/
lib-old
/
Para.pyc
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2005-10-18
|
10KB
|
376 lines
# Source Generated with Decompyle++
# File: in.pyc (Python 2.4)
Int = type(0)
class Para:
def __init__(self):
self.words = []
self.just = 'l'
self.indent_left = self.indent_right = self.indent_hang = 0
self.left = None
self.top = None
self.right = None
self.bottom = None
self.width = None
self.height = None
self.lines = None
def addword(self, d, font, text, space, stretch):
if font is not None:
d.setfont(font)
width = d.textwidth(text)
ascent = d.baseline()
descent = d.lineheight() - ascent
spw = d.textwidth(' ')
space = space * spw
stretch = stretch * spw
tuple = (font, text, width, space, stretch, ascent, descent)
self.words.append(tuple)
def bgn_anchor(self, id):
self.words.append(id)
def end_anchor(self, id):
self.words.append(0)
def getlength(self):
total = 0
for word in self.words:
if type(word) is not Int:
total = total + word[2] + word[3]
continue
return total
def tabto(self, tab):
total = 0
(as, de) = (1, 0)
for i in range(len(self.words)):
word = self.words[i]
if type(word) is Int:
continue
(fo, te, wi, sp, st, as, de) = word
self.words[i] = (fo, te, wi, sp, 0, as, de)
total = total + wi + sp
if total < tab:
self.words.append((None, '', 0, tab - total, 0, as, de))
def makehangingtag(self, hang):
self.tabto(hang)
self.indent_left = self.indent_left + hang
self.indent_hang = -hang
def layout(self, linewidth):
self.width = linewidth
height = 0
self.lines = lines = []
avail1 = self.width - self.indent_left - self.indent_right
avail = avail1 - self.indent_hang
words = self.words
i = 0
n = len(words)
lastfont = None
while i < n:
firstfont = lastfont
charcount = 0
width = 0
stretch = 0
ascent = 0
descent = 0
lsp = 0
j = i
while i < n:
word = words[i]
if type(word) is Int:
if word > 0 and width >= avail:
break
i = i + 1
continue
(fo, te, wi, sp, st, as, de) = word
if width + wi > avail and width > 0 and wi > 0:
break
if fo is not None:
lastfont = fo
if width == 0:
firstfont = fo
charcount = charcount + len(te) + (sp > 0)
width = width + wi + sp
lsp = sp
stretch = stretch + st
lst = st
ascent = max(ascent, as)
descent = max(descent, de)
i = i + 1
while i > j and type(words[i - 1]) is Int and words[i - 1] > 0:
i = i - 1
width = width - lsp
if i < n:
stretch = stretch - lst
else:
stretch = 0
tuple = (i - j, firstfont, charcount, width, stretch, ascent, descent)
lines.append(tuple)
height = height + ascent + descent
avail = avail1
self.height = height
def visit(self, wordfunc, anchorfunc):
avail1 = self.width - self.indent_left - self.indent_right
avail = avail1 - self.indent_hang
v = self.top
i = 0
for tuple in self.lines:
(wordcount, firstfont, charcount, width, stretch, ascent, descent) = tuple
h = self.left + self.indent_left
if i == 0:
h = h + self.indent_hang
extra = 0
if self.just == 'r':
h = h + avail - width
elif self.just == 'c':
h = h + (avail - width) / 2
elif self.just == 'lr' and stretch > 0:
extra = avail - width
v2 = v + ascent + descent
for j in range(i, i + wordcount):
word = self.words[j]
if type(word) is Int:
ok = anchorfunc(self, tuple, word, h, v)
if ok is not None:
return ok
continue
continue
(fo, te, wi, sp, st, as, de) = word
if extra > 0 and stretch > 0:
ex = extra * st / stretch
extra = extra - ex
stretch = stretch - st
else:
ex = 0
h2 = h + wi + sp + ex
ok = wordfunc(self, tuple, word, h, v, h2, v2, j == i, j == i + wordcount - 1)
if ok is not None:
return ok
h = h2
v = v2
i = i + wordcount
avail = avail1
def render(self, d, left, top, right):
if self.width != right - left:
self.layout(right - left)
self.left = left
self.top = top
self.right = right
self.bottom = self.top + self.height
self.anchorid = 0
try:
self.d = d
self.visit(self.__class__._renderword, self.__class__._renderanchor)
finally:
self.d = None
return self.bottom
def _renderword(self, tuple, word, h, v, h2, v2, isfirst, islast):
if word[0] is not None:
self.d.setfont(word[0])
baseline = v + tuple[5]
self.d.text((h, baseline - word[5]), word[1])
if self.anchorid > 0:
self.d.line((h, baseline + 2), (h2, baseline + 2))
def _renderanchor(self, tuple, word, h, v):
self.anchorid = word
def hitcheck(self, mouseh, mousev):
self.mouseh = mouseh
self.mousev = mousev
self.anchorid = 0
self.hits = []
self.visit(self.__class__._hitcheckword, self.__class__._hitcheckanchor)
return self.hits
def _hitcheckword(self, tuple, word, h, v, h2, v2, isfirst, islast):
if self.anchorid > 0:
pass
def _hitcheckanchor(self, tuple, word, h, v):
self.anchorid = word
def hasanchor(self, id):
if not id in self.words:
pass
return -id in self.words
def extract(self):
text = ''
for w in self.words:
if type(w) is not Int:
word = w[1]
if w[3]:
word = word + ' '
text = text + word
continue
return text + '\n'
def whereis(self, d, mouseh, mousev):
if mousev < self.top or mousev > self.bottom:
return None
self.mouseh = mouseh
self.mousev = mousev
self.lastfont = None
self.charcount = 0
try:
self.d = d
return self.visit(self.__class__._whereisword, self.__class__._whereisanchor)
finally:
self.d = None
def _whereisword(self, tuple, word, h1, v1, h2, v2, isfirst, islast):
(fo, te, wi, sp, st, as, de) = word
if fo is not None:
self.lastfont = fo
h = h1
if isfirst:
h1 = 0
if islast:
h2 = 999999
if self.lastfont is not None:
self.d.setfont(self.lastfont)
cc = 0
for c in te:
cw = self.d.textwidth(c)
if self.mouseh <= h + cw / 2:
return self.charcount + cc
cc = cc + 1
h = h + cw
self.charcount = self.charcount + cc
if self.mouseh <= (h + h2) / 2:
return self.charcount
else:
return self.charcount + 1
def _whereisanchor(self, tuple, word, h, v):
pass
def screenpos(self, d, pos):
if pos < 0:
(ascent, descent) = self.lines[0][5:7]
return (self.left, self.top, self.top + ascent, self.top + ascent + descent)
self.pos = pos
self.lastfont = None
try:
self.d = d
ok = self.visit(self.__class__._screenposword, self.__class__._screenposanchor)
finally:
self.d = None
if ok is None:
(ascent, descent) = self.lines[-1][5:7]
ok = (self.right, self.bottom - ascent - descent, self.bottom - descent, self.bottom)
return ok
def _screenposword(self, tuple, word, h1, v1, h2, v2, isfirst, islast):
(fo, te, wi, sp, st, as, de) = word
if fo is not None:
self.lastfont = fo
cc = len(te) + (sp > 0)
if self.pos > cc:
self.pos = self.pos - cc
return None
if self.pos < cc:
self.d.setfont(self.lastfont)
h = h1 + self.d.textwidth(te[:self.pos])
else:
h = h2
(ascent, descent) = tuple[5:7]
return (h, v1, v1 + ascent, v2)
def _screenposanchor(self, tuple, word, h, v):
pass
def invert(self, d, pos1, pos2):
if pos1 is None:
pos1 = (self.left, self.top, self.top, self.top)
else:
pos1 = self.screenpos(d, pos1)
if pos2 is None:
pos2 = (self.right, self.bottom, self.bottom, self.bottom)
else:
pos2 = self.screenpos(d, pos2)
(h1, top1, baseline1, bottom1) = pos1
(h2, top2, baseline2, bottom2) = pos2
if bottom1 <= top2:
d.invert((h1, top1), (self.right, bottom1))
h1 = self.left
if bottom1 < top2:
d.invert((h1, bottom1), (self.right, top2))
top1 = top2
bottom1 = bottom2
d.invert((h1, top1), (h2, bottom2))